import com.example.perplonews.a_b_entity.BaseEntity
import com.example.perplonews.a_b_utils.LjlUtils
import io.reactivex.Observer
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

open class BasePresenter<M : IModel, V : IVIew> : IPresenter, Observer<BaseEntity> {
    protected lateinit var mymodel: M
    protected lateinit var myview: V

    constructor(mymodel: M, myview: V) {
        this.mymodel = mymodel
        this.myview = myview

    }

    private var dispos = CompositeDisposable()

    override fun onSubscribe(d: Disposable) {
        dispos.add(d)
        myview.showDialog()
    }

    override fun onError(e: Throwable) {
        LjlUtils.Ljl_Loge(
            "BasePresenter____访问错误："+e.message.toString()

        )
    }

    override fun onComplete() {
        myview.hideDialog()
    }

    override fun onDestrory() {
        dispos.dispose()
        dispos.clear()
    }

    override fun onNext(t: BaseEntity) {
        LjlUtils.Ljl_Loge("----BasePresenter"+t.message)
        LjlUtils.Ljl_Loge("----BasePresenter"+t.status)
    }
}